package com.xbai.bean;

import org.springframework.beans.factory.annotation.Value;

/**
 * @author xbai
 * @Date 2021/3/26
 */
public class Person {

    // 使用@Value赋值
    //1、基本数值
    //2、可以写SpringEL表达式，#{}
    //3、可以写${}，取出配置文件【properties】中的值（或运行环境变量里面的值）
    @Value("张三")
    private String name;
    @Value("#{20-2}")
    private String age;
    @Value("${person.nickname}")
    private String nickname;

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public Person() {
    }

    public Person(String name, String age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age='" + age + '\'' +
                ", nickname='" + nickname + '\'' +
                '}';
    }
}
